package com.zyy.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyy.demo.dao.UserDao;
import com.zyy.demo.entity.User;
import com.zyy.demo.request.UserLoginRequest;
import com.zyy.demo.request.UserRequest;
import com.zyy.demo.response.UserResponse;
import com.zyy.demo.service.UserService;
import org.springframework.stereotype.Service;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

@Service
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {



    @Override
    public Boolean addUser(UserRequest userRequest) {
        User user = new User();
        user.set

        return null;
    }

    @Override
    public Boolean delUser(String iphone) {
        return null;
    }

    @Override
    public UserResponse login(UserLoginRequest userLoginRequest) {
        return null;
    }
    //SHA-256密码加密
    public static String encryptPassword(String password) throws NoSuchAlgorithmException {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(password.getBytes());

            byte[] digest = md.digest();

            StringBuilder sb = new StringBuilder();
            for (byte b : digest) {
                sb.append(String.format("%02x", b));
            }

            return sb.toString();
        }

        public static void main(String[] args) {
            try {
                String originalPassword = "123456"; // 假设这是从前端传来的密码
                String encryptedPassword = encryptPassword(originalPassword);
                System.out.println("Encrypted Password: " + encryptedPassword);
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            }
        }

}




